home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1996 #15
/
Monster Media Number 15 (Monster Media)(July 1996).ISO
/
prog_c
/
cuj0696.zip
/
DWYER.ZIP
/
SPECTRAL.TST
/
SPECTRAL.DOC
< prev
next >
Wrap
Text File
|
1996-01-26
|
6KB
|
184 lines
Description of Program Spectral January 26, 1996
INTRODUCTION
The purpose of program spectral is to check the quality of multi-
plier and modulus of linear congruential random number generators.
One-parameter and two-parameter generators can be handled.
Program spectral implements Knuth's Algorithm S (The Spectral
Test) [1, pp. 89-113]. The underlying theory is described on
pages 89-98 of [1]. The algorithm implemented is described on
pages 98-105. The generalization described in exercise 24, page
113 of [1] has also been implemented.
Program spectral employs software written by Steve Moshier [2] to
do 100-digit extended precision arithmetic.
This document describes how to use program spectral.
HOW TO USE PROGRAM SPECTRAL
Program spectral resides on disk as spectral.exe. Standard units
are used for input and output:
stderr - Prompts for inputs and and error messages
stdin - Input data
stdout - Results
Start program spectral by issuing the command
spectral
at the command line.
My favorite input technique is to prepare an input file with the
required data, one item per line. Then the redirect the input
unit with:
sepctral < [file name]
If you decide to enter the data directly, you will be prompted for
input data as follows:
How Many Multipliers? [1 or 2]:
Enter Multiplier:
Enter Modulus:
Enter Maximum Dimension:
The text shown is produced when you respond '1' to the first
prompt. You must enter either 1 or 2. If you don't, program
spectral issues a warning message and asks you to reenter the
input:
How Many Multipliers? [1 or 2]: 3
Incorrect Response: 3
- 1 -
Description of Program Spectral January 26, 1996
How Many Multipliers? [1 or 2]:
The following prompts are produced when you respond '2' to the
first prompt:
How Many Multipliers? [1 or 2]: 2
Enter First Multiplier:
Enter Second Multiplier:
Enter Modulus:
Enter Maximum Dimension:
For example, to replicate the numbers on line 27, page 102 of [1]
your responses must be:
How Many Multipliers? [1 or 2]: 1
Enter Multiplier: 314159269
Enter Modulus: 2147483647
Enter Maximum Dimension: 6
The only two-parameter generator illustrated in [1] is given on
line 28. Here is what your responses must be:
How Many Multipliers? [1 or 2]: 2
Enter First Multiplier: 271828183
Enter Second Multiplier: -314159269
Enter Modulus: 2147483647
Enter Maximum Dimension: 6
A requirement of the Spectral Test is that the multiplier(s) and
the modulus be relatively prime. When this is not the case, you
will be advised with a printout like the following:
Multiplier and modulus not relatively prime.
GCD of Multiplier and Modulus = xxxx
Error(s) detected in input data
The minimum dimension that is tested is 2. If you enter something
less than that your input is silently ignored.
OUTPUT FROM PROGRAM SPECTRAL
Standard Printouts
------------------
The first few lines of output echo your inputs. Thereafter, the
results of the Spectral Test are printed - two lines per dimension
requested. For example, when the test cited above for line 27
from [1] is run, the following output is produced:
1 Number of Multipliers
314159269 Multiplier
2147483647 Modulus
6 Maximum Dimension of Test
- 2 -
Description of Program Spectral January 26, 1996
2-Dimensional Accuracy = 1432232969 No. Bits: 15.2
2-Dimensional Merit = 2.10 (Good > 0.1, Great > 1.0)
3-Dimensional Accuracy = 899290 No. Bits: 9.9
3-Dimensional Merit = 1.66 (Good > 0.1, Great > 1.0)
4-Dimensional Accuracy = 36985 No. Bits: 7.6
4-Dimensional Merit = 3.14 (Good > 0.1, Great > 1.0)
5-Dimensional Accuracy = 3427 No. Bits: 5.9
5-Dimensional Merit = 1.69 (Good > 0.1, Great > 1.0)
6-Dimensional Accuracy = 1144 No. Bits: 5.1
6-Dimensional Merit = 3.60 (Good > 0.1, Great > 1.0)
The numbers that you see in this example exactly replicate those
given in [1]. The output you see here has been cropped to fit on
the page.
Error Printouts
---------------
As stated previously, you must enter 1 or 2 to the first prompt.
Failure to do so can result is severe mental anguish, to wit:
How Many Multipliers? [1 or 2]: 3 <-- Uncalled for
Incorrect Response: 3
How Many Multipliers? [1 or 2]:
It is a requirement that the multiplier(s) under test and the
modulus be relatively prime. When this is not the case, you are
shown the error of your ways as follows:
How Many Multipliers? [1 or 2]: 1
Enter Multiplier: 314159269
Enter Modulus: 2147483639
Multiplier and modulus not relatively prime.
GCD of Multiplier and Modulus = 17
Error(s) detected in input data
REFERENCES
1. Donald E. Knuth, The Art of Computer Programming, Second
Edition, Vol. 2, Seminumerical Algorithms, Addison-Wesley,
Reading, Mass. (1981).
2. Steven L. Moshier, Methods and Programs for Mathematical
Functions, Prentice-Hall (1989)
- 3 -